import React, { Component } from "react";
import CommentsLi from "./CommentsLi.js"

class Comments extends Component {
    constructor(props, context) {
        super(props)
        this.state = {
            data: []
        }
      }
    getCate(){
        fetch("/api/comments/list",{
            method:"POST"
        }).then(res=>{
            return res.json();
          }).then((data) => {
              this.setState({
                data:data
              })
        })
    }
    componentDidMount(){
        this.getCate();
    }
  render() {
    return (
      <div>
        <div
          className="beta-front-page-header hidden-xs"
          style={{ marginTop: "1%", marginBottom: "1%" }}
        >
          <b className="pantry-brown-title pantry-brown-title-pc">最新评论</b>
        </div>
        <div className="arc_div arc_div_center" >
          <div className="pl" style={{backgroundColor:'#f2f2f2'}}>
            <ul>
                {this.state.data.rows && this.state.data.rows.map(
                    (item,index) =>{
                        return   <CommentsLi data={item} key={index}/>
                    }
                )}
            </ul>
          </div>
        </div>
      </div>
    );
  }
}

export default Comments;
